<!DOCTYPE html>
<html>
	<head>
		<title></title>
	</head>
	<body>
		<section>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/observer/Notifier.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/help/adapters/NotifierAdapter.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/command/SimpleCommand.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/command/MacroCommand.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/observer/Notification.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/observer/Observer.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/proxy/Proxy.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/mediator/Mediator.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/core/Model.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/core/View.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/core/Controller.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/patterns/facade/Facade.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/help/adapters/FacadeAdapter.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/help/adapters/SimpleCommandAdapter.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/help/adapters/MacroCommandAdapter.js"></script>
			<script type="application/javascript" src="../../Asset/Source/org/puremvc/js/help/adapters/MediatorAdapter.js"></script>

			<script type="application/javascript">
				
				new function ()
				{
					
					var ApplicationConstants=
						{
							DO_START: 'doStart'
						,	HAS_STARTED: 'hasStarted'	
						,	DO_STOP: 'doStop'
						,	HAS_STOPPED: 'hasStopped'
						}
					
					////
						
					MockMediator.prototype= new MediatorAdapter;
					MockMediator.prototype.constructor= MockMediator;
					MockMediator.prototype.interests=
					[
						ApplicationConstants.HAS_STARTED
					,	ApplicationConstants.HAS_STOPPED
					]
					MockMediator.prototype.listNotificationInterests= function ()
					{
						return this.interests;
					};
					MockMediator.prototype.handleNotification= function (note)
					{
						switch(note.getName())
						{
							case ApplicationConstants.HAS_STARTED: 
								return this.onApplicationStarted(note);
								
							case ApplicationConstants.HAS_STOPPED: 
								return this.onApplicationStopped(note);
						}
					};
					
					MockMediator.prototype.onApplicationStarted= function ()
					{
						console.info('The application has started, drawing fancy site intro');
						this.sendNotification(ApplicationConstants.DO_STOP);
					};
					
					MockMediator.prototype.onApplicationStopped= function ()
					{
						console.info('The application has stopped, exiting with a bow');
						this.facade.removeMediator(this.getMediatorName());
					};
					
					MockMediator.prototype.onRegister= function ()
					{
						console.info('The mediator has been registered');
					};
					
					MockMediator.prototype.onRemove= function ()
					{
						console.info('The mediator has been removed');
					};
					
					
					MockMediator.NAME= 'MockMediator';
					
					function MockMediator ()
					{
						Mediator.apply(this, arguments);
					};
					
					////

					function DoStartCommand ()
					{
						SimpleCommand.call(this);
					};
					DoStartCommand.prototype= new SimpleCommandAdapter;
					DoStartCommand.prototype.execute= function ()
					{
						this.sendNotification(ApplicationConstants.HAS_STARTED);
					};
					
					////

					function DoStopCommand ()
					{
						SimpleCommand.call(this);
					};
					DoStopCommand.prototype= new SimpleCommandAdapter;
					DoStopCommand.prototype.execute= function (note)
					{
						this.sendNotification(ApplicationConstants.HAS_STOPPED);
					};
					
					////
					
					var	facade= Facade.getInstance()

					facade.registerMediator(new MockMediator);										
					facade.registerCommand(ApplicationConstants.DO_START, DoStartCommand);
					facade.registerCommand(ApplicationConstants.DO_STOP, DoStopCommand);
					
					
					facade.sendNotification(ApplicationConstants.DO_START);
				};

			</script>

		</section>
	</body>
</html>